<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>仓储管理|用户编辑</title>
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet" />
    <link th:href="@{/font-awesome/css/font-awesome.css}" rel="stylesheet" />

    <!-- Toastr style -->
    <link th:href="@{/css/plugins/toastr/toastr.min.css}" rel="stylesheet"/>

    <link th:href="@{/css/style.css}" rel="stylesheet" />


</head>

<body>

<div id="wrapper">
    <nav class="navbar-default navbar-static-side" role="navigation" th:include="nav :: navigation"></nav>
    <div id="page-wrapper" class="gray-bg">
        <div class="border-bottom" th:include="header :: headerTop"></div>
        <div class="wrapper wrapper-content animated fadeInRight">

            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>编辑用户</h5>
                            <div class="ibox-tools">
                                <a class="collapse-link">
                                    <i class="fa fa-chevron-up"></i>
                                </a>
                            </div>
                        </div>
                        <div class="ibox-content">
                            <form id="userForm" action="userEdit" method="POST" class="form-horizontal" enctype="multipart/form-data">
                                <input type="hidden" name="id" th:value="${user.id}" />

                                <div class="form-group"><label class="col-sm-2 control-label">登录名：</label>
                                    <div class="col-sm-10">
                                        <input id="loginName" name="loginName" type="text" class="form-control" th:value="${user.loginName}"/>
                                    </div>
                                </div>
                                <div class="form-group"><label class="col-sm-2 control-label">用户名：</label>
                                    <div class="col-sm-10">
                                        <input id="realName" name="realName" type="text" class="form-control" th:value="${user.realName}"/>
                                    </div>
                                </div>
                                <div class="form-group"><label class="col-sm-2 control-label">手机号码：</label>
                                    <div class="col-sm-10">
                                        <input id="mobile" name="mobile" type="text" class="form-control" th:value="${user.mobile}"/>
                                    </div>
                                </div>
                                <div class="form-group"><label class="col-sm-2 control-label">电子邮箱：</label>
                                    <div class="col-sm-10">
                                        <input id="email" name="email" type="text" class="form-control" th:value="${user.email}"/>
                                    </div>
                                </div>
                                <div class="form-group"><label class="col-sm-2 control-label">角色：</label>
                                    <div class="col-sm-10">
                                        <select name="roleId" id="roleId" class="form-control" >
                                            <option value="0" th:selected="${user.roleId==0}">--请选择角色--</option>
                                            <option th:each="role : ${roles}" th:value="${role.id}" th:text="${role.name}" th:selected="${user.roleId==role.id}"></option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group"><label class="col-sm-2 control-label">状态：</label>
                                    <div class="col-sm-10">
                                        <select name="status" id="status" class="form-control" >
                                            <option value="0" th:selected="${user.status==0}">--请选择状态--</option>
                                            <option th:each="us : ${userStatus}" th:value="${us.id}" th:text="${us.name}" th:selected="${user.status==us.id}"></option>
                                        </select>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group"><label class="col-sm-2 control-label">描述：</label>
                                    <div class="col-sm-10">
                                        <textarea id="description" name="description" class="form-control" rows="2" th:text="${user.description}"></textarea>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>

                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-2">
                                        <button id="submitButton" class="btn btn-primary" type="button">&nbsp;&nbsp;&nbsp;&nbsp;保&nbsp;&nbsp;&nbsp;&nbsp;存&nbsp;&nbsp;&nbsp;&nbsp;</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <div class="footer" th:include="footer :: copyright"></div>
    </div>
</div>

<!-- Mainly scripts -->
<script th:src="@{/js/jquery-2.1.1.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/js/plugins/metisMenu/jquery.metisMenu.js}"></script>
<script th:src="@{/js/plugins/slimscroll/jquery.slimscroll.min.js}"></script>

<!-- Peity -->
<script th:src="@{/js/plugins/peity/jquery.peity.min.js}"></script>

<!-- Custom and plugin javascript -->
<script th:src="@{/js/inspinia.js}"></script>
<script th:src="@{/js/plugins/pace/pace.min.js}"></script>

<!-- Toastr script -->
<script th:src="@{/js/plugins/toastr/toastr.min.js}"></script>

<!-- common -->
<script th:src="@{/js/common.js}"></script>


<script th:inline="javascript">
    $(document).ready(function () {
        $("#submitButton").click(function(){
            if($("#loginName").val() == ""){
                toastr.error('请输入登录名','提示')
                return;
            }
            if($("#realName").val() == ""){
                toastr.error('请输入用户名','提示')
                return;
            }
            if($("#roleId").val() == 0){
                toastr.error('请选择角色','提示')
                return;
            }
            if($("#status").val() == 0){
                toastr.error('请选择状态','提示')
                return;
            }
            $("#userForm").submit();
        });
    });

</script>

</body>

</html>
